﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.DataSourcesFile;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Controls;

namespace WindowsFormsApp1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
        }

        private void textBox1_Click(object sender, EventArgs e)
        {
            textBox1.Text = MyTools.OpenFile("添加dbf对象", "dbf file (*.dbf) |*.dbf");
            textBox1.Enabled = false;
            MyTools.MakeCombo(ref comboBox1, MyTools.AddDbfTable(textBox1.Text));
        }

        private void textBox2_Click(object sender, EventArgs e)
        {
            textBox2.Text = MyTools.OpenFile("添加dbf对象", "dbf file (*.dbf) |*.dbf");
            textBox2.Enabled = false;
            MyTools.MakeCombo(ref comboBox2, MyTools.AddDbfTable(textBox2.Text));
        }

        private void button2_Click(object sender, EventArgs e)
        {
            ITable basic = null,Join = null;
            Task task1 = Task.Run(() =>
            {
                basic = MyTools.AddDbfTable(textBox1.Text);
            });
            Task task2 = Task.Run(() =>
            {
                Join = MyTools.AddDbfTable(textBox2.Text);
            });
            task1.Wait();
            task2.Wait();
            if (basic == null || Join == null || comboBox1.Text == null || comboBox2.Text == null)
            {
                MessageBox.Show("输入不正确");
                return;
            }
            button2.Enabled = false;
            ITable OutTable = MyTools.JoinFieldAPI(basic, Join, comboBox1.Text, comboBox2.Text);
            DataTable table = MyTools.ToDataTable(OutTable);
            button2.Enabled = true;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void Form2_Load(object sender, EventArgs e)
        {

        }
    }
}
